package com.dbgs.insurance.insuredperson.activity;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Color;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.ViewGroup.LayoutParams;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.dbgs.insurance.insuredperson.R;


public class MainTabHelper {
    Context mContext;
    int[] stateSelectArr = new int[]{android.R.attr.state_checked,};
    int[] stateUnSelectArr = new int[]{-android.R.attr.state_checked,};
    RadioGroup.LayoutParams layoutParams;
    //	String[] nameArr;
    LayoutInflater mInflater;
    Resources res;

    public MainTabHelper(Context mContext) {
        super();
        this.mContext = mContext;
        mInflater = LayoutInflater.from(mContext);
        res = mContext.getResources();
        layoutParams = new RadioGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1.0f);
    }

    public RadioButton getTabRadioBtn(int type, String color) {//"#ff7200"

        RadioButton radioBtn = (RadioButton) mInflater.inflate(R.layout.main_tab_radiobtn, null);
        radioBtn.setLayoutParams(layoutParams);
        radioBtn.setGravity(Gravity.CENTER);
        int checkedColor = 0;
        if (TextUtils.isEmpty(color)) {
            checkedColor = mContext.getResources().getColor(R.color.color_main);
        } else {
            checkedColor = Color.parseColor(color);
        }
        int defaultColor = mContext.getResources().getColor(R.color.color_shallow_gray);
//		boolean isDefault = color.equals("#ff7200") ?true : false;

        ColorStateList textcolor = new ColorStateList(
                new int[][]{{android.R.attr.state_checked}, {-android.R.attr.state_checked}},
                new int[]{checkedColor, defaultColor});
        radioBtn.setTextColor(textcolor);

        switch (type) {
            case 0:
                radioBtn.setId(R.id.radiobtn_main_home_page);
                break;
            case 1:
                radioBtn.setId(R.id.radiobtn_main_infor);
                break;
            case 2:
                radioBtn.setId(R.id.radiobtn_main_min);
                break;

            default:
                break;
        }
        return radioBtn;
    }

}
